<cfcomponent extends="assets.calgrants.com.Base">

	<cfscript>
        import assets.calgrants.com.bo.StudentFacebook;
	</cfscript>
	
	<cffunction name="get" access="public" output="false" returntype="assets.calgrants.com.bo.StudentFacebook">
		<cfargument name="Student_Facebook_ID" type="numeric" required="true" />
		<cfscript>
			if (arguments.Student_Facebook_ID gt 0) {
				local.loadArgs = {};
				local.loadArgs.obj = new StudentFacebook();
				StructAppend(local.loadArgs, QueryToStruct(read(argumentCollection = arguments))[1]);
				return load(argumentCollection = local.loadArgs);
			} else {
				return new StudentFacebook();
			}
		</cfscript>
	</cffunction>
	
	<cffunction name="load" access="public" output="false" returntype="assets.calgrants.com.bo.StudentFacebook">
		<cfargument name="obj" type="assets.calgrants.com.bo.StudentFacebook" required="true" />
		<cfscript>
			local.obj = arguments.obj;
			if (IsDefined("arguments.Student_Facebook_ID")) {
				local.obj.setStudent_Facebook_ID(arguments.Student_Facebook_ID);
			}
			if (IsDefined("arguments.Deleted")) {
				local.obj.setDeleted(arguments.Deleted);
			}
			if (IsDefined("arguments.Facebook_ID")) {
				local.obj.setFacebook_ID(arguments.Facebook_ID);
			}
			if (IsDefined("arguments.Student_ID")) {
				local.obj.setStudent_ID(arguments.Student_ID);
			}
			if (IsDefined("arguments.First_Name")) {
				local.obj.setFirst_Name(arguments.First_Name);
			}
			if (IsDefined("arguments.Last_Name")) {
				local.obj.setLast_Name(arguments.Last_Name);
			}
			if (IsDefined("arguments.Link")) {
				local.obj.setLink(arguments.Link);
			}
			if (IsDefined("arguments.Name")) {
				local.obj.setName(arguments.Name);
			}
			if (IsDefined("arguments.Username")) {
				local.obj.setUsername(arguments.Username);
			}
			if (IsDefined("arguments.Location_Name")) {
				local.obj.setLocation_Name(arguments.Location_Name);
			}
			if (IsDefined("arguments.Gender")) {
				local.obj.setGender(arguments.Gender); 
			}
			if (IsDefined("arguments.Date_Created")) {
				local.obj.setDate_Created(arguments.Date_Created);
			}
			return local.obj;
		</cfscript>
	</cffunction>

	<cffunction name="read" access="public" output="false" returntype="any">
		<cfargument name="Student_Facebook_ID" required="false" default="" />
		<cfargument name="Deleted" required="false" default="0" />
		<cfargument name="Facebook_ID" required="false" default="" />
		<cfargument name="Student_ID" required="false" default="" />
		<cfargument name="First_Name" required="false" default="" />
		<cfargument name="Last_Name" required="false" default="" />
		<cfargument name="Link" required="false" default="" />
		<cfargument name="Name" required="false" default="" />
		<cfargument name="Username" required="false" default="" />
		<cfargument name="Location_Name" required="false" default="" />
		<cfargument name="Gender" required="false" default="" />
		<cfargument name="Date_Created" required="false" default="" />

		<cfset var recs = "">
		<cfstoredproc datasource="#getDatasource()#" procedure="readStudentFacebook">
			<cfprocparam value="#arguments.Student_Facebook_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Student_Facebook_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Deleted#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Deleted)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Facebook_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Facebook_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Student_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Student_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.First_Name#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.First_Name)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Last_Name#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Last_Name)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Link#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Link)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Name#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Name)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Username#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Username)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Location_Name#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Location_Name)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Gender#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Gender)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Date_Created#" cfsqltype="CF_SQL_TIMESTAMP" null="#IIf(Len(Trim(arguments.Date_Created)) eq 0, true, false)#" />
			<cfprocresult name="recs" />
		</cfstoredproc>
		<cfreturn recs />
	</cffunction>

	<cffunction name="save" access="public" output="false" returntype="any">
		<cfargument name="studentFacebook" required="true" type="assets.calgrants.com.bo.StuentFacebook" />

		<cfstoredproc datasource="#getDatasource()#" procedure="saveStudentFacebook">
			<cfprocparam value="#studentFacebook.getStudent_Facebook_ID()#" cfsqltype="CF_SQL_INTEGER" variable="id" type="inout" null="false" />
			<cfprocparam value="#studentFacebook.getDeleted()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#studentFacebook.getFacebook_ID()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#studentFacebook.getStudent_ID()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#studentFacebook.getFirst_Name()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#studentFacebook.getLast_Name()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#studentFacebook.getLink()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(studentFacebook.getLink())) eq 0, true, false)#" />
			<cfprocparam value="#studentFacebook.getName()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(studentFacebook.getName())) eq 0, true, false)#" />
			<cfprocparam value="#studentFacebook.getUsername()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(studentFacebook.getUsername())) eq 0, true, false)#" />
			<cfprocparam value="#studentFacebook.getLocation_Name()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(studentFacebook.getLocation_Name())) eq 0, true, false)#" />
			<cfprocparam value="#studentFacebook.getGender()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(studentFacebook.getGender())) eq 0, true, false)#" />
		</cfstoredproc>
		<cfreturn id />
	</cffunction>

	<cffunction name="destroy" access="public" output="false" returntype="any">
		<cfargument name="Student_Facebook_ID" required="true" />

		<cfstoredproc datasource="#getDatasource()#" procedure="destroyStudentFacebook">
			<cfprocparam value="#arguments.Student_Facebook_ID#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="true" cfsqltype="CF_SQL_BIT" null="false" />
		</cfstoredproc>
		<cfreturn true />
	</cffunction>

</cfcomponent>

